#!/bin/sh

kpasswdd_start() {
  if [ -x /usr/libexec/kpasswdd ]; then
    echo "Starting the kpasswdd service: /usr/libexec/kpasswdd"
    /usr/libexec/kpasswdd --detach
  fi
}

kpasswdd_stop() {
  killall kpasswdd
}

kpasswdd_restart() {
  kpasswdd_stop
  sleep 1
  kpasswdd_start
}

case "$1" in
  'start')
    kpasswdd_start
  ;;
  'stop')
    kpasswdd_stop
  ;;
  'restart')
    kpasswdd_restart
  ;;
  *)
    echo "Usage: $0 start|stop|restart"
  ;;
esac

